package CtrLayer;
import ModelLayer.*;


/**
 * Write a description of class ContractorCtr here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class ContractorCtr
{
    // instance variables - replace the example below with your own
    private static ContractorList instance = ContractorList.getInstance();

    /**
     * Constructor for objects of class ContractorCtr
     */
    public ContractorCtr()
    {
        // initialise instance variables
        
    }

    public void createContractor(int i, String n, String a, String pc, String ph, String e, String desc)
    {
        Contractor con = new Contractor(i, n, a, pc, ph, e, desc);
        instance.addContractor(con);
    }
    
    public boolean deleteContractor(int id)
    {
        return instance.deleteContractor(id);
    }
    
    public Contractor getContractor(int id)
    {
        return instance.getContractor(id);
    }
    
    public boolean updateContractor(int i, String updateValue, int opt)
    {
        Contractor ct = getContractor(i);
        try{
            switch(opt){
                case 1 : { ct.setName(updateValue); } break;
                case 2 : { ct.setAddress(updateValue); } break;
                case 3 : { ct.setPostCode(updateValue); } break;
                case 4 : { ct.setPhone(updateValue); } break;
                case 5 : { ct.setEmail(updateValue); } break;
                case 6 : { ct.setDescription(updateValue); } break;
            }
            return true;
        }
        catch(Exception e) {}
        return false;
    }
}
